package com.woniuxy.microfundservice.controller;

import com.alibaba.fastjson.JSONObject;
import com.woniuxy.bean.ResultBean;
import com.woniuxy.microfundservice.bean.info.FundGrades;
import com.woniuxy.microfundservice.service.FundGradesService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * (FundGrades)表控制层
 *
 * @author makejava
 * @since 2021-04-08 09:34:13
 */
@RefreshScope
@Api("基金评级")
@RestController
@RequestMapping(value = "/fundGrades", produces = MediaType.APPLICATION_JSON_VALUE)
public class FundGradesController {
    /**
     * 服务对象
     */
    @Resource
    private FundGradesService fundGradesService;

    /**
     * 通过基金主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @ApiOperation("根据基金id查找评级")
    @GetMapping("/selectOne")
    public ResultBean selectOne(Integer id) {

        List<FundGrades> fundGrades = fundGradesService.selectOne(id);

        return ResultBean.builder().code(200).data(fundGrades).build();
    }

    @ApiOperation("新增基金评级")
    @PostMapping("/addone")
    public ResultBean addOne(@RequestBody List<FundGrades> fundGrades){

        int res=fundGradesService.addOne(fundGrades);
        return ResultBean.builder().code(200).msg("新增成功").build();
    }

    @ApiOperation("修改基金评级")
    @PutMapping("/updateOne")
    public ResultBean updateOne(@RequestBody FundGrades fundGrades){
        int res=fundGradesService.updateOne(fundGrades);
        return ResultBean.builder().code(200).msg("修改成功").build();
    }


}